<template>
  <!-- 弹出层 -->
  <div class="modal fade cooDeptAuditModal"
       id="cooDeptAuditModal"
       tabindex="-1"
       role="dialog"
       aria-labelledby="myModalLabel"
       aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button"
                  class="close"
                  data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
          <h4 class="modal-title title"
              id="myModalLabel">合作机构审核</h4>
        </div>
        <div class="modal-body">
          <div class="form-horizontal">
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">公司名称：</label>
              <div class="col-sm-6 eachContent">
                {{cooDeptAudit.companyName}}
              </div>
            </div>
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">省份：</label>
              <div class="col-sm-6 eachContent">
                {{cooDeptAudit.provinceName}}
              </div>
            </div>
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">城市：</label>
              <div class="col-sm-6 eachContent">
                {{cooDeptAudit.cityName}}
              </div>
            </div>
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">详细地址：</label>
              <div class="col-sm-6 eachContent">
                {{cooDeptAudit.adress}}
              </div>
            </div>
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">管理员姓名：</label>
              <div class="col-sm-6 eachContent">
                {{cooDeptAudit.adminName}}
              </div>
            </div>
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">管理员电话：</label>
              <div class="col-sm-6 eachContent">
                {{cooDeptAudit.adminPhone}}
              </div>
            </div>
            <div class="form-group"
                 v-for="item in cooDeptAudit.modelInfoResDtoList">
              <label class="col-sm-5 control-label">{{item.name}}：</label>
              <div class="col-sm-6 contentTextTwo"
                   v-if="item.displayType==='1' && item.value">
                <img :src="item.value"
                     alt=""
                     class="itemImg">
              </div>
              <div class="col-sm-6 contentText"
                   v-else>{{item.value || ''}}
              </div>
            </div>
            <div class="form-group">
              <label for=""
                     class="col-sm-5 control-label">审核意见：</label>
              <div class="col-sm-6 contentText"
                   v-if="editFlag">
                <RadioGroup v-model="cooDeptAudit.status"
                            size="small">
                  <Radio label="2"
                         style="margin-right:50px;">通过</Radio>
                  <Radio label="1">不通过</Radio>
                </RadioGroup>
              </div>
              <div class="col-sm-6 eachContent"
                   v-else>
                {{cooDeptAudit.status | filterStatus}}
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-5 control-label">备注：</label>
              <div v-if="editFlag"
                   class="col-sm-6">
                <Input v-model="cooDeptAudit.remark"
                       style="width:70%"
                       show-word-limit
                       type="textarea"
                       :rows="4"
                       :maxlength="20"
                       placeholder="请输入备注，不超过20字" />
              </div>
              <div v-else
                   class="col-sm-6 contentText">{{cooDeptAudit.remark || ''}}
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer modal-footerRight">
          <button v-if="editFlag"
                  type="button"
                  class="btn btn-default"
                  data-dismiss="modal">取消</button>
          <button v-if="editFlag"
                  type="button"
                  class="btn checkedBtn"
                  @click="cooDeptAuditSubmit">确定</button>
          <button type="button"
                  @click="closeModal"
                  v-if="!editFlag"
                  class="btn checkedBtn">关闭</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  //接收父组件的绑定值
  props: ["cooDeptAudit", "editFlag"],
  data() {
    return {};
  },
  filters: {
    filterStatus(v) {
      if (v === "0") {
        return "待审核";
      } else if (v === "1") {
        return "审核失败";
      } else if (v === "2") {
        return "审核通过";
      }
    }
  },
  watch: {},
  methods: {
    closeModal() {
      $("#cooDeptAuditModal").modal("hide");
    },
    cooDeptAuditSubmit() {
      if (
        this.cooDeptAudit.status !== "1" &&
        this.cooDeptAudit.status !== "2"
      ) {
        layer.msg("请选择审核意见", {
          time: 2000
        });
        return false;
      }
      var _self = this;
      const params = {
        checkCompanyId: this.cooDeptAudit.id,
        checkStatus: this.cooDeptAudit.status,
        remark: this.cooDeptAudit.remark
      };
      _self.btnShow = false;
      var url = _self.utilHelper.apiUrl + "/api/agentCompanyCheck";
      _self.$http.post(url, { params }).then(
        (response) => {
          if (response.body.result === "1") {
            layer.msg(
              "审核成功",
              {
                time: 1000
              },
              function () {
                $("#cooDeptAuditModal").modal("hide");
                //子组件向父组件传递信号: 调用父组件中对子组件的监听
                _self.$emit("cooDeptAuditListener");
              }
            );
          } else {
            layer.msg(response.body.errorMsg, {
              time: 1000
            });
            return false;
          }
        },
        (response) => {}
      );
    }
  }
};
</script>
<style lang="less" scoped>
.cooDeptAuditModal {
  .eachContent {
    padding-top: 7px;
  }
  .contentText {
    color: #515a6e;
    font-size: 12px;
    padding-top: 7px;
  }
  .contentTextTwo {
    color: #515a6e;
    font-size: 12px;
    padding-top: 7px;
    height: 100px;
    .itemImg {
      width: auto;
      height: 100%;
    }
  }
  .ivu-radio-wrapper {
    font-size: 12px !important;
  }
  .add-huxing {
    width: 130px !important;
    height: 120px;
    position: relative;
    padding: 15px !important;
    border: 1px dashed #e2e2e2;
    background-color: #fff;
    text-align: center;
    cursor: pointer;
    color: #999;
    display: inline-block;
    margin: 20px 0 50px 0;
  }
  .over-img {
    margin-left: 10px;
    margin-top: 0px;
  }
  .title {
    text-align: center;
  }
  .modal-footerRight {
    text-align: right;
  }
}
</style>